import re
import os

def extract_params_from_filename(file_path):
    """
    从文件路径中提取 node, proc, iteration, cn_start, cn_end
    
    参数:
        file_path (str): 文件路径
        
    返回:
        dict: 包含提取参数的字典（含cn范围）
    """
    filename = os.path.basename(file_path)
    params = {}
    
    # 提取 node (如 4node)
    node_match = re.search(r'(\d+)node', filename)
    if node_match:
        params['node'] = int(node_match.group(1))
    
    # 提取 proc (如 8proc)
    proc_match = re.search(r'(\d+)proc', filename)
    if proc_match:
        params['proc'] = int(proc_match.group(1))
    
    # 提取 iteration (如 10interation)
    iter_match = re.search(r'(\d+)interation', filename)
    if iter_match:
        params['iteration'] = int(iter_match.group(1))
    
    # 新增：提取 cn 后的数字范围 (如 cn[9561-9564])
    cn_match = re.search(r'(cn\[[^\]]+\])', filename)
    if cn_match:
        params['cn_match'] = cn_match.group(1)
    
    return params